<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			function getData(){
				let xhr = new XMLHttpRequest()
				xhr.open("GET","data.txt",true)
				xhr.send()
				xhr.onreadystatechange = function(){
					if(xhr.readyState==4 && xhr.status==200){
						let data = xhr.responseText
						document.querySelector("span").innerHTML = data
					}
				}
			}
		</script>
	</head>
	<body>
		异步请求到的文本数据是：<span></span><br>
		<button type="button" onclick="getData()">请求数据</button>
	</body>
</html>
